#pragma once
#include "SipRobot.h"

class CSIPTerminalActor : public CBaseActor
{

public:
    CSIPTerminalActor (CSipRobot* pSip); 
    virtual ~CSIPTerminalActor () ;
   
	int HandleWaitReg();
	
    int HandleRegister();
    
    int HandleRegisterAuth();
    
    int HandleIdle();
   
private:
	CSipRobot*  mpSipTerminal;
};
//-----------------------------------------------------------
class CWaitRegisterFsm : public IFsmState
{
public:
    CWaitRegisterFsm () {}
    virtual ~CWaitRegisterFsm () {}
    virtual int BeginState(IActor* obj)
    {
        //cout<<"Init WaitSend"<<endl;
        return 0;
    }
    virtual int UpDataState(IActor* obj)
    {
        //cout<<"Process WaitSend"<<endl;
		 CSIPTerminalActor * chirdObj = (CSIPTerminalActor*) obj;
		return  chirdObj->HandleWaitReg();
       
    }
    virtual int EndState(IActor* obj)
    {
        //cout<<"Fini WaitSend"<<endl;
        return 0;
    }
};

class CRegisterFsm : public IFsmState
{
public:
    CRegisterFsm () {}
    virtual ~CRegisterFsm () {}
    virtual int BeginState(IActor* obj)
    {
        //cout<<"Init WaitSend"<<endl;
        return 0;
    }
    virtual int UpDataState(IActor* obj)
    {
        CSIPTerminalActor * chirdObj = (CSIPTerminalActor*) obj;
		return  chirdObj->HandleRegister();      
    }
    virtual int EndState(IActor* obj)
    {
        //cout<<"Fini WaitSend"<<endl;
        return 0;
    }
};

class CRegisterAuthFsm : public IFsmState
{
public:
    CRegisterAuthFsm () {}
    virtual ~CRegisterAuthFsm () {}
    virtual int BeginState(IActor* obj)
    {
        //cout<<"Init Sending"<<endl;
        return 0;
    }
    virtual int UpDataState(IActor* obj)
    {
        //cout<<"Process Sending"<<endl;
        CSIPTerminalActor * chirdObj = (CSIPTerminalActor*) obj;
        int ret = chirdObj->HandleRegisterAuth();
        if (ret > 0)
        {
            return ret;
        }
        return 0;
    }
    virtual int EndState(IActor* obj)
    {
        //cout<<"Fini Sending"<<endl;
        return 0;
    }
};

class CSIPTerminalKeepFsm : public IFsmState
{
public:
    CSIPTerminalKeepFsm () {}
    virtual ~CSIPTerminalKeepFsm () {}
    virtual int BeginState(IActor* obj)
    {
        //cout<<"Init SendOver"<<endl;
        return 0;
    }
    virtual int UpDataState(IActor* obj)
    {
        CSIPTerminalActor * chirdObj = (CSIPTerminalActor*) obj;
        int ret = chirdObj->HandleIdle();
      
		return ret;
    }
    virtual int EndState(IActor* obj)
    {
        //cout<<"Fini SendOver"<<endl;
        return 0;
    }
};